//
//  SISSProtocolViewController.m
//  SISSAPP
//
//  Created by 优房网 on 2017/3/21.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSProtocolViewController.h"
#import <WebKit/WebKit.h>

@interface SISSProtocolViewController ()

@property (nonatomic, strong) WKWebView *webView;

@end

@implementation SISSProtocolViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.title = @"深圳市房地产中介协会交易通使用协议";
    // 添加左上角返回按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
}


/**
 返回按钮点击事件
 */
- (void)back {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - UI
- (void)setupSubviews {
    [super setupSubviews];
    
    WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
    // 自适应屏幕宽度js
    NSString *jSString = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
    WKUserScript *wkUserScript = [[WKUserScript alloc] initWithSource:jSString injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
    // 添加自适应屏幕宽度js调用的方法
    WKUserContentController *wkUController = [[WKUserContentController alloc] init];
    [wkUController addUserScript:wkUserScript];
    wkWebConfig.userContentController = wkUController;
    
    WKWebView *webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:wkWebConfig];
    [self.view addSubview:webView];

    NSString *urlStr = [NSString stringWithFormat:@"%@/%@",WEB_BASE_URL,URL_LOGIN_AGREEMENT];
//    NSString *urlStr = [NSString stringWithFormat:@"%@/%@",@"http://jyt.szfzx.org",URL_LOGIN_AGREEMENT];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]];
    [webView loadRequest:request];
}



@end
